<template>
	<view>
		<navbar mode="search" @input="input" @search="search"></navbar>
		<view class="showList">
			<view class="title" v-for="(item,index) in showTitles">
				<text>{{item}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				inputText:"",
				showTitles:[],
				goodsList:[]
			}
		},
		onLoad(){
			var vue = this
			this.$request("goods/getAll",null,function(res){
				vue.goodsList = res.data.data
			})
		},
		methods: {
			input(data){
				this.showTitles = [];
				this.inputText = data;
				/* var index = 0;
				if(this.inputText !== "" && this.inputText !== " "){
					for(var i in this.goodsList){
						if(this.goodsList[i].title.indexOf(this.inputText) >= 0){
							this.$set(this.showTitles,index++,this.goodsList[i].title)
						}
					}
				} */
			},
			search(){
				if(this.inputText !== ""){
					this.confirm(this.inputText)
				}
			},
			confirm(text){
				uni.navigateTo({
					url:"../../../search-goods-list/search-goods-list?text="+text
				})
			}
		}
	}
</script>

<style lang="scss">
	.showList{
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		.title{
			height: 70rpx;
			width: 98%;
			border-bottom: 2rpx #ccc solid;
			display: flex;flex-direction: row;
			align-items: center;
			margin-top: 10rpx;
			
			text{
				font-size: 36rpx;
				margin-left: 20rpx;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
				text-overflow: ellipsis;
				overflow: hidden;
				display: -webkit-box;
			}
		}
	}
</style>
